
		
		
		
		<div class="easyui-layout" data-options="fit:true">
			<table id="partSizeStatisticTable" class="easyui-datagrid" style="height:100%;">
				<thead frozen="true">
					<tr>
						<th data-options="field:'date',width:100,align:'center'">日期</th>
						<th data-options="field:'weight',width:100,align:'center'">体重</th>
					</tr>
				</thead>
				<thead>
						<tr>
							<%if(!isEmpty(parts)){
								for(part in parts){
										var colspan  = @com.xpgk.mvc.codeSet.Code.cacheGetChild(part.ids).size();
									%>
									<th data-options="field:'${part.code! }',width:100,align:'center',colspan:${colspan }" >${part.name! }</th>
								<%}%>
							<%}%>
						</tr>
						<tr>
							<%if(!isEmpty(parts)){
								for(part in parts){
										var _parts  = @com.xpgk.mvc.codeSet.Code.cacheGetChild(part.ids);
										for(p in _parts){%>
											<th data-options="field:'${p.code! }',width:50,align:'center'" >${p.name! }</th>
										<%}%>
								<%}%>
							<%}%>
							<th data-options="field:'sum',width:50,align:'center',hidden:true" ></th>
						</tr>
					</thead>
			</table>
			<div id="partSizeStatistic_tb" >
				日期：
				<input id="partSizeStatistic_startTime" value='${startTime! }' class="easyui-datebox theme-textbox-radius"  data-options="editable: false"/>~
				<input id="partSizeStatistic_endTime" value='${date(),dateFormat="yyyy-MM-dd"}' class="easyui-datebox theme-textbox-radius" data-options="editable: false"/>
			</div>
		</div>
		<script type="text/javascript">
			$(document).ready(function () {
				//加载数据表格
				loadPartSizeStatisticTable();
				$('#partSizeStatistic_startTime').datebox({
					onSelect: function(date){
						loadPartSizeStatisticTable();
					}
				});
				$('#partSizeStatistic_endTime').datebox({
					onSelect: function(date){
						loadPartSizeStatisticTable();
					}
				});
			});
			
			function  loadPartSizeStatisticTable() {	
				var startTime = $("#partSizeStatistic_startTime").val();
				var endTime = $("#partSizeStatistic_endTime").val();
				$('#partSizeStatisticTable').datagrid({
					cls: "theme-datagrid",
					toolbar: '#partSizeStatistic_tb',
					singleSelect: true,
					rownumbers: true, //显示序号
					url: "${cxt!}/customerInfoStatistic/lookCustomerPartSizeStatistic",
					queryParams: {
						'customerIds': '${customerIds! }',
						'startTime': startTime,
						'endTime': endTime
					},
				    method: 'post',
					collapsible: true,
					onLoadSuccess:function(){
						var rows = $('#partSizeStatisticTable').datagrid('getRows');
						if(rows.length > 0){
							$('#partSizeStatisticTable').datagrid('appendRow', {
								date: '累计减尺',
								weight: partSize_diff('weight'),
								<%
									if(!isEmpty(parts)){
										for(part in parts){
											var _parts  = @com.xpgk.mvc.codeSet.Code.cacheGetChild(part.ids);
											for(p in _parts){
												print(p.code + ': partSize_diff(\'' + p.code + '\'),');
											}
										}
									}
								%>
								sum: partSize_diff('sum')
				             });
						}
					},
				})
			}
			
			//指定列求累计
	        function partSize_diff(colName) {
	             var rows = $('#partSizeStatisticTable').datagrid('getRows');
	             var diff = 0;
	             var length = rows.length;
	             var before = parseFloat(rows[0][colName]);
	             var after = parseFloat(rows[length-1][colName]);
	             diff = (before - after).toFixed(1);
	             return diff;
	         }
			
		</script>
		
